#include <stdio.h> 
#define MAXS 10

char *match( char *s, char ch1, char ch2 );

int main()
{
    char str[MAXS], ch_start, ch_end, *p;

    scanf("%s\n", str);
    scanf("%c %c", &ch_start, &ch_end);
    p = match(str, ch_start, ch_end);
    printf("%s\n", p);

    return 0;
}
char *match( char *s, char ch1, char ch2 ){
    int t=0,i=0;
    while(*(s+i)!=ch2&&*(s+i)!='\0'){
          i++;
        if(*(s+i)==ch1){
            t=1;
        }
        if(t==1){
            printf("%c",*s);
        }
    }
    i=0;
    if(t==0){
         while(*(s+i)!=ch2&&*(s+i)!='\0'){
          i++;
             printf("%c",*s);
         }
    }
   return s; 
    
    
    
}
